package com.lyh.handler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;

import com.lyh.model.UserStatusEnum;


public class UserTypeHandler implements TypeHandler<UserStatusEnum> {
	
	public UserStatusEnum getResult(ResultSet rs, String columnName)
			throws SQLException {
		return UserStatusEnum.codeOf(rs.getInt(columnName));
	}

	public UserStatusEnum getResult(ResultSet rs, int columnIndex)
			throws SQLException {
		return UserStatusEnum.codeOf(rs.getInt(columnIndex));
	}

	public UserStatusEnum getResult(CallableStatement cs, int columnIndex)
			throws SQLException {
		return UserStatusEnum.codeOf(cs.getInt(columnIndex));
	}

	public void setParameter(PreparedStatement ps, int i,
			UserStatusEnum parameter, JdbcType arg3) throws SQLException {
		ps.setInt(i, parameter.getCode());
	}

}
